home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE6 / PD / PDF / GuiLib / Wimp / h / GuiWimpMessage < prev    next >
Text File  |  2003-02-14  |  5KB  |  157 lines

  1. //--------------------------------------------------------------------------
  2. //
  3. //   Copyright (c) 2002, Colin Granville
  4. //
  5. //   All rights reserved.
  6. //
  7. //   Redistribution and use in source and binary forms, with or
  8. //   without modification, are permitted provided that the following 
  9. //   conditions are met:
  10. //
  11. //      * Redistributions of source code must retain the above copyright 
  12. //        notice, this list of conditions and the following disclaimer.
  13. //
  14. //      * Redistributions in binary form must reproduce the above 
  15. //        copyright notice, this list of conditions and the following 
  16. //        disclaimer in the documentation and/or other materials 
  17. //        provided with the distribution.
  18. //
  19. //      * The name Colin Granville may not be used to endorse or promote 
  20. //        products derived from this software without specific prior 
  21. //        written permission.
  22. //
  23. //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  24. //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  25. //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  26. //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  27. //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  28. //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  29. //   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  30. //   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  31. //   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  32. //   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  33. //   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
  34. //   OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //--------------------------------------------------------------------------
  37.  
  38. #ifndef GuiWimpMessage_h
  39. #define GuiWimpMessage_h
  40.  
  41. // GuiMouseClickBlock defined in GuiWimp.h before including this file
  42. // #include GuiWimp.h to use this header
  43.  
  44. #define GuiWimp_MQuit                          0
  45. #define GuiWimp_MDataSaveAck                   2
  46. #define GuiWimp_MDataLoad                      3
  47. #define GuiWimp_MDataLoadAck                   4
  48. #define GuiWimp_MDataOpen                      5
  49.  
  50. #define GuiWimp_MPrintFile                     0x80140
  51. #define GuiWimp_MWillPrint                     0x80141
  52. #define GuiWimp_MPrintSave                     0x80142
  53. #define GuiWimp_MPrintInit                     0x80143
  54. #define GuiWimp_MPrintError                    0x80144
  55. #define GuiWimp_MPrintTypeOdd                  0x80145
  56. #define GuiWimp_MPrintTypeKnown                0x80146
  57. #define GuiWimp_MSetPrinter                    0x80147
  58.  
  59. class GuiWimpMessageBase
  60. {
  61.   public:
  62.     struct 
  63.     {
  64.         int    size;
  65.         int    sender;
  66.         int    myRef;
  67.         int    yourRef;
  68.         int    actionCode;
  69.     } hdr;
  70.  
  71.     // all methods return myRef uno
  72.  
  73.     // sends set your_ref to 0
  74.     // if window_or_dest_task_handle==0 then message is broadcast
  75.  
  76.     int send(int mess_code,int window_or_dest_task_handle=0,int icon_handle=0);
  77.     int sendRecorded(int mess_code,int window_or_dest_task_handle=0,int icon_handle=0);
  78.  
  79.     //replies set your_ref=my_ref;
  80.  
  81.     int reply(int mess_code);
  82.     int replyRecorded(int mess_code);
  83.     int acknowledge();
  84.  
  85.  
  86.     // to is a char* in the GuiWimpMessage
  87.     // sets hdr.size
  88.     // returns ptr to terminating 0 or zero if to not in header;
  89.     char* copyString(char* to,const char* from);
  90.  
  91.     // char* points to end of string (after terminating 0)
  92.     // sets to GuiWimpMessage::MAX_SIZE if not valid ptr
  93.     void setSize(const char*);
  94.  
  95. };
  96.  
  97.  
  98. class GuiPointerPosition
  99. {
  100.   public:
  101.       int   windowHandle;
  102.       int   iconHandle;
  103.       int   x;
  104.       int   y;
  105.       
  106.       void set(GuiMouseClickBlock& p) {windowHandle=p.windowHandle,iconHandle=p.iconHandle,x=p.x,y=p.y;}
  107.       void set(int w,int i,int _x,int _y)      {windowHandle=w,iconHandle=i,x=_x,y=_y;}
  108.       void operator()(GuiMouseClickBlock& p)   {set(p);}
  109.       void operator()(int w,int i,int x,int y) {set(w,i,x,y);}
  110. };
  111.  
  112. struct GuiWimpDataSaveMessage
  113. {
  114.   public:
  115.     GuiPointerPosition destination;
  116.     int                estimatedSize;
  117.     int                fileType;
  118.     char               leafName [212];
  119. };
  120.  
  121. struct  GuiWimpDataSaveAckMessage : public GuiWimpDataSaveMessage {};
  122. struct  GuiWimpDataLoadMessage : public GuiWimpDataSaveMessage {};
  123. struct  GuiWimpDataLoadAckMessage : public GuiWimpDataSaveMessage {};
  124.  
  125.  
  126. struct GuiWimpDataOpen
  127. {
  128.     int   windowHandle;
  129.     int   padding1;
  130.     int   x;
  131.     int   y;
  132.     int   padding2;
  133.     int   fileType;
  134.     char  pathName[212];
  135. };
  136.  
  137.  
  138. //***************************************************************************
  139.  
  140. class GuiWimpMessage : public GuiWimpMessageBase
  141. {
  142.   public:
  143.     enum {MAX_SIZE=256};
  144.     union
  145.     {
  146.         GuiWimpDataSaveMessage       dataSave;
  147.         GuiWimpDataSaveAckMessage    dataSaveAck;
  148.         GuiWimpDataLoadMessage       dataLoad;
  149.         GuiWimpDataLoadAckMessage    dataLoadAck;
  150.         GuiWimpDataOpen              dataOpen;
  151.     } data;
  152.  
  153. };
  154.  
  155.  
  156. #endif
  157.